<header>
    <style>

.onlyforemployee,.onlyforhead,.onlyforhr{
    display:none;
}
<?
if (isset($_SESSION['loggedinuserishead']))
    echo '.onlyforhead{display: inline-flex;}';
if (isset($_SESSION['loggedinuserishrexec']))
    echo '.onlyforhr{display: inline-flex;}';
if (!(isset($_SESSION['loggedinuserishead']) or isset($_SESSION['loggedinuserishrexec'])))
    $_SESSION['loggedinuserisemployee'] = true;
echo '.onlyforemployee{display: inline-flex;}';
?>

<?
if (isset($_SESSION['loggedinuser'])) {
    echo '.invisibleforuser';
} else {
    echo '.invisibleforguest';
}
?>{
    display: none;
}
    </style>
    <nav>
        <ul class="navbar" >

            <li><a href="/">Home</a></li>
            <?
            if (isset($_SESSION['loggedinuserishrexec']) && $_SESSION['loggedinuserishrexec'] == true)
                echo '<li><a class="invisibleforguest" href="/add-master-training">Add Master Training</a></li>';
            if (isset($_SESSION['loggedinuser']))
                echo '<li><a class="invisibleforguest" href="/apply-for-training">Apply For Training</a></li>';
            if (isset($_SESSION['loggedinuserishead'])&&$_SESSION['loggedinuserishead'] == true)
                echo '<li><a class="invisibleforguest" href="/add-master-training">Register Employees for Training</a></li>';
            if (isset($_SESSION['loggedinuserishead'])&&$_SESSION['loggedinuserishead'] == true)
                echo '<li><a class="invisibleforguest onlyforhead" href="/add-master-training">Training Requests</a></li>';
            if (isset($_SESSION['loggedinuser']))
                echo '<li><a class="invisibleforguest " href="/add-master-training">Leave Feedback</a></li>';
            ?>
            <li class="invisibleforuser"><a href="/signup">Sign Up</a></li>
            <li class="invisibleforuser"><a href="/login">Sign In</a></li>
            <li class="invisibleforguest"><a href="/submit/logout">Sign Out</a></li>
        </ul>
    </nav>
    <?
    if (isset($_SESSION["errormessage"])) {
        echo '<div id="errormessage" class="message">' . $_SESSION["errormessage"] . '</div>';
        unset($_SESSION["errormessage"]);
    }
    if (isset($_SESSION["infomessage"])) {
        echo '<div id="infomessage" class="message">' . $_SESSION["infomessage"] . '</div>';
        unset($_SESSION["infomessage"]);
    }
?>
</header>